package lion.blog;

import java.util.List;

import lion.blog.model.BlogSetting;
import lion.dev.lang.MapJ;
import lion.framework.core.db.DB;
import lion.framework.core.web.ApplicationContext;
import lion.web.platform.events.anno.On;

/**
 * @author lion
 * @email hl_0074@sina.com
 * @date 2015年11月20日
 */
public class BlogEventHandler {

	@On("blog.setting:change")
	public void onBlogSettingChanged(DB db) {

		List<BlogSetting> blocks = BlogSetting.list(-1, db);

		MapJ codeBlock = new MapJ();
		for (BlogSetting cb : blocks) {
			codeBlock.put(cb.getCode(), cb.getValue());
		}

		ApplicationContext.set("blog", codeBlock);
	}
}
